/*
 * Copyright 2010. 
 * 
 * This document may not be reproduced, distributed or used 
 * in any manner whatsoever without the expressed written 
 * permission of xrkol Corp. 
 * 
 * $Rev: Rev $
 * $Author: Author $
 * $LastChangedDate: LastChangedDate $
 *
 */

package com.xrkol.sharelib.service.impl;

import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xrkol.sharelib.dao.TopicDao;
import com.xrkol.sharelib.entity.Clazz;
import com.xrkol.sharelib.entity.Topic;
import com.xrkol.sharelib.service.TopicService;

/**
 * @author peng.xia
 *
 */
@Service
@Transactional
public class TopicServiceImpl implements TopicService{

    @Autowired
    private TopicDao topicDao;
    
    @Override
    public void save(Topic entity) {
        this.topicDao.save(entity);
    }

    @Override
    public void update(Topic entity) {
        this.topicDao.update(entity);
    }

    @Override
    public void delete(String id) {
        this.topicDao.delete(id);
    }

    @Override
    public Topic findById(String id) {
        return this.topicDao.findById(id);
    }

    @Override
    public List<Topic> getTopics(Clazz clazz, Integer page) {
         List<Topic> topics = this.topicDao.getTopics(clazz, page);
         if(topics == null){
             return Collections.emptyList();
         }
         return topics;
    }

    @Override
    public List<Topic> getTopics(List<String> classIds, Integer page) {
        List<Topic> topics = this.topicDao.getTopics(classIds, page);
        if(topics == null){
            return Collections.emptyList();
        }
        return topics;
    }

}
